package org.example.model.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * @author weigang
 * @create 2022-11-08 14:43
 */
@Data
public class FullUserDto implements Serializable {

    private static final long serialVersionUID = 3979326829751465305L;

    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;

    /**
     * 用户名/itcode
     */
    @Size(max = 50, message = "length more then 50")
    @NotBlank(message = "not null")
    private String userName;

    /**
     * 锁定标记（0 未锁定 1锁定）
     */
    @Range(min = 0, max = 32767, message = "between 0 and 32767")
    @NotNull(message = "not null")
    private Integer lockFlag;

    /**
     * 手机号
     */
    @Size(max = 20, message = "length more then 20")
    private String phone;

    /**
     * 邮箱
     */
    @Size(max = 50, message = "length more then 50")
    private String email;

    /**
     * 部门表id
     */
    @NotNull(message = "not null")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long deptId;

    /**
     * 最后登录时间
     */
    private LocalDateTime lastLoginTime;

    /**
     * 最后登录ip
     */
    @Size(max = 50, message = "length more then 50")
    private String lastLoginAddr;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime createTime;

    /**
     * 创建用户
     */
    private String createBy;

    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime updateTime;

    /**
     * 修改用户
     */
    private String updateBy;

    /**
     * 逻辑删除（1 删除 0 未删除）
     */
    private Integer isDeleted;


    /**
     *  数据权限，基于部门，仅在缓存中
     */
    private Set<String> scopedUsersByDept;

    /**
     *  数据权限，基于team和部门，仅在缓存中
     */
    private Set<String> scopedUsers;
}
